package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.RagflowUser;
import com.ruoyi.business.service.IRagflowUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * raglow用户列表Controller
 * 
 * @author ruoyi
 * @date 2025-03-12
 */
@RestController
@RequestMapping("/business/ragflowUser")
public class RagflowUserController extends BaseController
{
    @Autowired
    private IRagflowUserService ragflowUserService;

    /**
     * 查询raglow用户列表列表
     */
    @PreAuthorize("@ss.hasPermi('business:ragflowUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(RagflowUser ragflowUser)
    {
        startPage();
        List<RagflowUser> list = ragflowUserService.selectRagflowUserList(ragflowUser);
        return getDataTable(list);
    }

    /**
     * 导出raglow用户列表列表
     */
    @PreAuthorize("@ss.hasPermi('business:ragflowUser:export')")
    @Log(title = "raglow用户列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RagflowUser ragflowUser)
    {
        List<RagflowUser> list = ragflowUserService.selectRagflowUserList(ragflowUser);
        ExcelUtil<RagflowUser> util = new ExcelUtil<RagflowUser>(RagflowUser.class);
        util.exportExcel(response, list, "raglow用户列表数据");
    }

    /**
     * 获取raglow用户列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:ragflowUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(ragflowUserService.selectRagflowUserById(id));
    }

    /**
     * 新增raglow用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:ragflowUser:add')")
    @Log(title = "raglow用户列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RagflowUser ragflowUser)
    {
        return toAjax(ragflowUserService.insertRagflowUser(ragflowUser));
    }

    /**
     * 修改raglow用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:ragflowUser:edit')")
    @Log(title = "raglow用户列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RagflowUser ragflowUser)
    {
        return toAjax(ragflowUserService.updateRagflowUser(ragflowUser));
    }

    /**
     * 删除raglow用户列表
     */
    @PreAuthorize("@ss.hasPermi('business:ragflowUser:remove')")
    @Log(title = "raglow用户列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(ragflowUserService.deleteRagflowUserByIds(ids));
    }
}
